<?php

namespace App\Http\Service;

use Illuminate\Support\Facades\DB;

/**
 * 消息分发
 * Class Msg
 * @package App\Http\Service
 */
class Msg
{
    protected $common;
    public function __construct()
    {
        $this->common = new Common;
    }

    /**
     * 聊天消息停止分发
     * @param $chatroomId    聊天室 Id。（必传）
     * @return mixed
     * @url https://docs.rongcloud.cn/im/server/chatroom/message_distribution/
     */
    public function stopChat($chatroomId){
        return $this->common->curl("/chatroom/message/stopDistribution",array('chatroomId'=>$chatroomId));
    }

    /**
     * 聊天消息恢复分发
     * @param $chatroomId    聊天室 Id。（必传）
     * @return mixed
     * @url https://docs.rongcloud.cn/im/server/chatroom/message_distribution/
     */
    public function resumeChat($chatroomId){
        return $this->common->curl("/chatroom/message/resumeDistribution",array('chatroomId'=>$chatroomId));
    }

    /**
     * 聊天室消息发送
     */
    public function publish(){
        return $this->common->curl("/message/chatroom/publish",array(
            'fromUserId'   => 1,   //发送消息的用户id
            'toChatroomId' => 1,   //聊天室id,
            'objectName'   => 'notice',
            'content'      => "我来了"
        ));
    }
}
